<template>
    <view class="order-submit-list">
        <view class="order-item">
            <order-submit-item v-for="proItem in item.CarList" :key="proItem.ID" :data="item"
                :isChangPrice="isChangPrice" :item.sync="proItem" @changeSuc="changeSuc"
                @changePolicy="changePolicy"></order-submit-item>
            <view><order-submit-item v-for="gift in giftList" :key="gift.ID" :data="gift" :item="gift"
                    :gift="1"></order-submit-item></view>
        </view>
        <!-- 		<view class="policy-price-box" v-if="item.Discount>0">
			<text class="label-text">优惠:{{item.PolicyName}}</text>
			<text>- ￥{{item.Discount}}</text>
		</view>
		<view v-if="item && item.GiftList && item.GiftList.length>0">
			<text class="price-text">赠品</text>
			<view class="" v-for="(giftItem,giftIndex) in item.GiftList" :key="giftIndex">
				<text>{{giftItem.ProductName}} x{{giftItem.Amount}}</text>
			</view>
		</view>
		<view  class="policy-after-price" v-if="item.Discount>0 && false">
			<text class="price-text">￥{{getTotal(item)}}</text>
		</view> -->
    </view>
</template>

<script>
import orderSubmitItem from "@/components/order/order-submit-item.vue"
export default {
    components: {
        orderSubmitItem,
    },
    props: {
        item: {
            type: Object,
            default: {},
        },
        giftList: {
            type: Array,
            default: () => [],
        },
        isChangPrice: {
            type: Number,
            default: 0,
        },
    },
    watch: {
        item(val) {
            this.item = val
            this.$emit("update:item", val)
        },
    },
    data() {
        return {}
    },
    mounted() {
        console.log(this.item)
    },
    methods: {
        getTotal(item) {
            let total = 0
            console.log(item)
            item.CarList.forEach((e) => {
                total += e.TotalMoney
            })
            return total - item.Discount
        },
        changePolicy(e) {
            this.$emit("changePolicy", e)
        },
        changeSuc() {
            this.$emit("changeSuc")
        }
    },
}
</script>

<style lang="scss">
.order-submit-list {
    background-color: $color-white;
    border-radius: $border-radius-10;
    // margin-bottom: 20rpx;
    padding: $app-page-padding $app-page-padding 0 $app-page-padding;

    .policy-price-box {
        display: flex;
        flex-direction: row;
        height: 60rpx;
        align-items: center;

        .label-text {
            flex: 1;
        }
    }

    .policy-after-price {
        display: flex;
        flex-direction: row;
        height: 60rpx;
        align-items: center;
        justify-content: flex-end;
    }
}
</style>
